<template>
	<Nav class="f" bgColor="#fff">
		<view class="title dispaly-center p-l-32 nav" @click="$goUrl('back')">
			<view class="icon dispaly-align-center">
				<!-- <image src="/static/icon/left.png" mode="aspectFill"></image> -->
				<u-icon name="arrow-left" color="#020121" size="34"></u-icon>
			</view>
			<view class="r-name">{{title}}</view>
		</view>
	</Nav>
	<view :style="{marginTop: navHeiht+ 'px'}">
		<view class="content p-32">
			<scroll-view :scroll-x="true" class="scroll-Y " :style="{marginTop: navHeiht+ 'px'}">
				<view @click="clickCate(item, index)" :class="{'ac': current == index}"
					class="cate-item over-1 dispaly-align-center" v-for="(item, index) in cateList" :key="index">
					{{item.name}}
				</view>
			</scroll-view>
			<view class="list">
				<PictureCard />
			</view>
		</view>
	</view>

</template>

<script setup>
	import {
		ref,
		onMounted
	} from 'vue'
	import {
		getElementHeight
	} from '@/utils/util'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import PictureCard from '@/compoment/card/pictureCard.vue'

	const cateList = ref([{
		name: '欧版西装',
		id: 1
	}])

	// 点击分类
	const current = ref(0)
	const clickCate = (item, index) => {
		current.value = index
	}

	const title = ref('')
	onLoad((option) => {
		for (var i = 0; i < 30; i++) {
			cateList.value.push({
				name: `欧版西装${i}`,
				id: i
			})
		}
		title.value = option.title
	})

	// 获取元素高度
	const navHeiht = ref(0)
	onMounted(async () => {
		const res = await getElementHeight('.f')
		navHeiht.value = res
	})
</script>

<style lang="scss" scoped>
	.home-content {
		margin: 0 32rpx;
	}

	.ac {
		font-weight: 500 !important;
		font-size: 28rpx !important;
		color: #FFFFFF !important;
		background: #020121;
	}

	.r-name {
		color: #020121;
	}

	.title {
		.icon {
			image {
				width: 40rpx;
				height: 40rpx;
			}
		}
	}

	.content {
		.list {
			margin-top: 70rpx;
		}

		scroll-view {
			display: flex;
			align-items: center;
			// height: 100rpx;
			white-space: nowrap;
			position: fixed;
			left: 0;
			top: 0;
			right: 0;
			z-index: 999;
			background-color: #fff;
			padding: 0 32rpx;
			justify-content: flex-end;

			.cate-item {
				margin-right: 16rpx;
				display: inline-block;
				font-family: Source Han Sans, Source Han Sans;
				font-weight: 500;
				font-size: 28rpx;
				color: #020121;
				width: 176rpx;
				height: 64rpx;
				border-radius: 8rpx;
				border: 2rpx solid #020121;
				line-height: 64rpx;
				text-align: center;
			}
		}
	}
</style>

<style>
	page {
		background-color: #fff;
	}
</style>